<template>
  <div class="log-page">
    <el-form inline>
      <el-form-item label="处理状态">
        <el-select v-model="searchParams.state" clearable placeholder="选择处理状态">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="冻结状态">
        <el-select v-model="searchParams.isFrozen" clearable placeholder="选择冻结状态">
          <el-option
            v-for="item in options2"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="选择日期">
        <el-date-picker
          v-model="searchParams.queryTime"
          format="yyyy-MM-dd"
          value-format="yyyy-MM-dd"
          type="date"
          placeholder="请选择日期"
        />
      </el-form-item>
      <el-form-item label="企业名称">
        <el-input v-model="searchParams.enterpriseName" clearable placeholder="输入企业名称" />
      </el-form-item>
      <el-form-item label="手机号">
        <el-input v-model="searchParams.phone" clearable placeholder="输入手机号" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" style="margin-left: 15px" @click="onSearch">搜索</el-button>
      </el-form-item>

    </el-form>
    <div class="line" />
    <div class="table-box">
      <el-table
        v-loading="loading"
        height="100%"
        stripe
        :data="tableData"
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(255, 255, 255, 0.8)"
        @selection-change="onSelect"
      >
        <el-table-column
          v-for="item in columns"
          :key="item.prop"
          :prop="item.prop"
          :label="item.label"
          align="center"
        />
        <el-table-column label="操作" fixed="right" width="120px">
          <template slot-scope="scope">
            <el-button
              type="text"
              @click="openDetail(row)"
            >详情</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="page-box">
      <el-pagination
        background
        :current-page="pageNo"
        :page-sizes="pageSizes"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totalSize"
        @size-change="changePageSize"
        @current-change="changePageNo"
      />
    </div>
    <AuditDetail ref="AuditDetail" />
  </div>
</template>

<script>
import crud from '@/mixins/crud';
import AuditDetail from '@/views/brand/page1/auditDetail';
import { http_brand_apply } from '@/api';
import { enterpriseTypeMap, isFrozenMap } from '@/dict';
export default {
  name: 'Index',
  components: {
    AuditDetail
  },
  mixins: [crud],
  data() {
    return {
      request: http_brand_apply,
      options: [
        {
          value: '0',
          label: '审核中'
        },
        {
          value: '1',
          label: '审核失败'
        },
        {
          value: '2',
          label: '审核成功'
        }
      ],
      options2: [
        {
          value: '0',
          label: '解冻'
        },
        {
          value: '2',
          label: '冻结'
        }
      ],
      searchParams: {
        enterpriseName: '',
        queryTime: '',
        phone: '',
        state: '',
        isFrozen: ''
      },
      tableData: [
      ],
      columns: [
        { prop: 'enterpriseName', label: '企业名称' },
        { prop: 'enterpriseTypeName', label: '企业类型' },
        { prop: 'userName', label: '姓名' },
        { prop: 'phone', label: '手机号' },
        { prop: 'queryTime', label: '申请日期', minWidth: '220px' },
        { prop: 'isFrozenName', label: '状态' }
      ]
    }
  },
  methods: {
    formatTableData(data) {
      data.forEach(el => {
        el.enterpriseTypeName = enterpriseTypeMap[el.enterpriseType]
        el.isFrozenName = isFrozenMap[el.isFrozen]
      })
    },
    openDetail(row) {
      this.$refs.AuditDetail.open(row)
    }
  }
}
</script>

<style scoped lang="scss">
.log-page {
  display: flex;
  flex-direction: column;
  background-color: #fff;
  height: 100%;
}
</style>
